/*
 * FinishedGameState.java
 *
 * Created on May 8, 2007, 10:01 PM
 *
 * Copyright (c) 2007 Daniel Gronau
 *
 * This file is part of KanjiTori.
 *
 * KanjiTori is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * KanjiTori is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

package kanjitori.gamestate;

import com.jme.input.KeyInput;
import com.jme.input.controls.GameControl;
import com.jme.input.controls.GameControlManager;
import com.jme.input.controls.binding.KeyboardBinding;
import com.jme.input.controls.binding.MouseButtonBinding;
import com.jme.input.controls.controller.ActionController;
import com.jme.input.controls.controller.GameControlAction;
import com.jme.scene.Node;
import com.jmex.game.state.BasicGameState;
import kanjitori.Main;
import kanjitori.gamestate.screen.FinishedGameScreen;
import kanjitori.graphics.ortho.status.PauseScreen;
import kanjitori.stats.Statistics;

/**
 *
 * @author DGronau
 */
public class FinishedGameState extends BasicGameState {
    
    /** Creates a new instance of FinishedGameState */
    public FinishedGameState() {
        super("finished");
        initInput();
    }
    
    private void initInput() {
        GameControlManager manager = new GameControlManager();
        
        GameControl leaveCtrl = manager.addControl("leave");
        leaveCtrl.addBinding(new KeyboardBinding(KeyInput.KEY_ESCAPE));
        leaveCtrl.addBinding(new KeyboardBinding(KeyInput.KEY_SPACE));
        leaveCtrl.addBinding(new KeyboardBinding(KeyInput.KEY_RETURN));
        leaveCtrl.addBinding(new MouseButtonBinding(0));        
        leaveCtrl.addBinding(new MouseButtonBinding(1));        
        getRootNode().addController(new ActionController(leaveCtrl,
                new GameControlAction() {
            public void pressed(GameControl gc, float time) {
                Main.exitGame();
            }
            public void released(GameControl gc, float time) {}
        }
        ));
    }
    
    public void setStatistics (Statistics stats) {
        new FinishedGameScreen(stats, getRootNode());
    }
    
}
